package com.zhihesj.anan.system.controller;


import cn.hutool.core.bean.BeanUtil;
import com.zhihesj.anan.message.Message;
import com.zhihesj.anan.system.entity.OperLog;
import com.zhihesj.anan.system.service.OperLogService;
import com.zhihesj.anan.system.vo.OperLogVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 操作日志记录 前端控制器
 * </p>
 *
 * @author anan
 * @since 2020-07-31
 */
@RestController
@RequestMapping("/system/oper-log")
public class OperLogController {

    @Autowired
    private OperLogService operLogService;

    @GetMapping("/getOperLogList")
    public Message getOperLogList(OperLogVo operLogVo){
        System.out.println(operLogVo);
        Map<String, Object> stringObjectMap = BeanUtil.beanToMap(operLogVo, false, true);
        if (stringObjectMap.isEmpty()) {
            List<OperLog> operLogs = operLogService.list();
            return Message.success(operLogs);
        } else {
            List<OperLog> operLogs = operLogService.list();
            return Message.success(operLogs);
        }
    }
}
